﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>贡献查询</title>
    <script src="../../Scripts/jquery-1.9.1.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .show_tp{  margin-bottom:10px;}
        .show_content{ margin:0px auto; width:900px;}
        .select_table{width:800px; border-color:#1C1C1C; overflow:scroll;text-align:center;border-collapse:collapse; border-spacing:0; margin-bottom:10px;  margin-top:5px;}
      .select_table th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px; }
      .pager{ margin-left:25%;  padding-top:20px;}
      .Menubox{height:28px;border-bottom:1px solid #C6E2FF;width:900px;}
	.Menubox ul{list-style:none;margin:7px;padding:0;position:absolute;}
	.Menubox ul li{float:left;background:#619FE0;line-height:20px;display:block;cursor:pointer;width:100px;text-align:center;color:#fff;font-weight:bold;border-top:1px solid #C6E2FF;border-left:1px solid #C6E2FF;border-right:1px solid #C6E2FF;}
	.Menubox ul li.hover{background:#fff;border-bottom:1px solid #fff;color:#4169E1;}
    .Contentbox{clear:both;margin-top:0px;border-top:none;height:100%;padding:15px; width:869px; border-bottom:1px solid #C6E2FF; border-right:1px solid #C6E2FF; border-left:1px solid #C6E2FF;}
    </style>
</head>
<body class="main">
     <div class="AllWebTopDiv">
        <div class="path">
            <div class="nav">
                <a href="#">用户贡献查询</a>
            </div>
        </div>
        <div class="content">
         <div class="show_content">
           <div class="show_tp" id="show_tp">
             <label>显示数据：</label><input id="show_Num"  type="text" value="10" style="width:100px;" />条&nbsp;&nbsp;
           </div>
           <div class="Menubox">
                    <ul>
                        <li id="menu1" onmouseover="setTab('menu',1,2)" class="hover">数据</li>
                        <li id="menu2" onmouseover="setTab('menu',2,2)">图表</li>
                    </ul>
                </div>
          <div class="Contentbox">
           <div id="con_menu_1">
           <table  class="select_table">
             <tr class="DGHeaderStyle">
               <th>会员卡号</th>
               <th>贡献总额</th>
               <th>会员姓名</th>
               <th>卡片类型</th>
             </tr>
           </table>
             <div class="pager">
                           <input  type="button" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('首页')"style="cursor:pointer"  value="首页" class="button"/>
                            <input type="button" value="上一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('上一页')"style="cursor:pointer" class="button"/>
                            <input type="button" value="下一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('下一页')"style="cursor:pointer" class="button"/>
                            <input type="button" value="末页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('末页')"style="cursor:pointer" class="button"/>
      
       　                    共 <label id="maxPage">1</label> 页 第 <label id="CurrentPage">1</label> 页
              </div>
              </div>
            <div id="con_menu_2" style="display: none">
            <img id="chart" src="<%:Url.Action("getChart","CustomerContributeChart") %>" alt="未找到数据"/>
            </div>
            </div>
        </div>
      </div>
    </div>
</body>
</html>
<script type="text/javascript">
   
  
    var pageNum=1;
    var pageSize=10;
    var show_Num=$("#show_Num").val();
     var strId="0";

      $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadMemberType","CustomerContributeChart") %>",
            data:"",
            cache:false,
            success:function(html)
            {
                $(".show_tp").append(html);
               
            }
            });
    window.onload=loadData();
    function loadData() { 
        $.ajax({
            type:"POST",
            url:"<%:Url.Action("LoadTabel","CustomerContributeChart") %>",
            data:"pageSize="+pageSize+"&show_Num="+show_Num+"&strId="+strId+"",
            cache:false,
            success:function(txt)
            {
                $(".DGHeaderStyle").nextAll().remove();
                $(".select_table").append(txt); 
                newPage("首页");
            }
           });

              $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","CustomerContributeChart") %>",
            data:"pageSize="+pageSize+"&show_Num="+show_Num+"&strId="+strId+"",
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        });
    }

       function newPage(sa)
        {
           var CurrentPage= $("#CurrentPage").html();
             var maxPage=$("#maxPage").html();
           
            maxPage=parseInt(maxPage);
            
            
            if(sa=="首页")
            {
                pageNum=1;
               document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="下一页")
            {
                 if(CurrentPage>=maxPage)
                {
                     alert("已是最大页数");
                    return;
                }
                pageNum++;
                document.getElementById("CurrentPage").innerHTML=pageNum;
               
            }
            if(sa=="上一页")
            {
                 if(CurrentPage==1)
            {
              alert("已是最小页数");
                return;
            } 
                pageNum--;
                document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="末页")
            {
                pageNum=maxPage;
                 document.getElementById("CurrentPage").innerHTML=pageNum;
            }
              $.ajax({
                type:"POST",
                url:"<%:Url.Action("newPage","CustomerContributeChart") %>",
                data:"pageNum="+pageNum+"&pageSize="+pageSize+"&show_Num="+show_Num+"&strId="+strId+"",
                cache:false,
                success:function(txt)
                {
                   $(".DGHeaderStyle").nextAll().remove();
                   $(".select_table").append(txt); 
                }
            })
        }

     //搜索 
      function searchData()
      {
         if (!String.prototype.trim) {
            var TRIM_REG = /(^\s*)|(\s*$)/g;
            String.prototype.trim = function () { return this.replace(TRIM_REG, ''); }
        }
        show_Num = document.getElementById('show_Num').value.trim(); 
        if (show_Num.length !=0) {
            reg = /^[-+]?\d*$/;
             if (!reg.test(show_Num)) {
               alert("显示数量应为整数");
              return false;

             }
            }
          else{
            alert("数量不能为空");
            return false;
          }
          
         var list=  document.getElementById("show_tp").getElementsByTagName("input");
         strId="";
         for(var i=0;i<list.length;i++)
         {
           if(list[i].type=="checkbox"){ 
            var test=document.getElementById(list[i].id).checked;
            if(test){ 
              strId +=list[i].id+","; 
            }
           }
         }
         strId=strId.substring(0,strId.length-1);
         if(strId.length <=0){
           alert("请至少勾选一种类型");
           return false;
         } 
        loadData(); 
       $("#chart").attr("src","/CustomerContributeChart/getChart?strId="+strId+"&show_Num="+show_Num+"");
   }


    //更换选项卡
    function setTab(name, cursel, n) {
        for (i = 1; i <= n; i++) {
            var menu = document.getElementById(name + i);
            var con = document.getElementById("con_" + name + "_" + i);
            menu.className = i == cursel ? "hover" : "";
            con.style.display = i == cursel ? "block" : "none";
        }
    }
     //关闭窗口
      function closeWindows() {
          window.location.href = "/Loading/Index/?src=/Desktop/Index/";
      }
</script>